<template>
	<view class="repair-wrap">
		<!-- <viewData :type="'noData'" :nextPage="!nextPage" :isTab="false" :isData="listData.length < 1" :loading="loading"
				  > -->
		<view class="nav_item" style="margin-top: -10px;" v-show="depomentData" v-for="(item,index) in depomentData" :key="index">
			<view class="repair-box "
				style="width: 100%;position: fixed;background: #fff;z-index: 10; padding: 0 60rpx;border-bottom: 2rpx solid #ccc;padding-bottom:20rpx">
				<view style="margin: 0 auto;">
					<view @click="handlerClickOne(index)">
						<view style="display: flex;">
							<view v-if="item.CentJi == 'pro'">
								<image style="width: 50px;height: 50px;border-radius: 50%;"
									src="../../static/image/mailProImg.png"></image>
							</view>

							<view style="margin-top: 8px;margin-left: 16px;">
								<view>
									<text>{{item.projectName}}物业管理中心</text>
								</view>
								<view style="margin-top: 5px;color: #999999;">
									电话：{{item.projectPhone ? item.projectPhone : '暂无'}}<text></text></view>
							</view>
						</view>
						<view style="float: right;margin-top: -46px;">
							<image v-if="item.CentJi == 'pro'" style="width: 28px;height: 28px;margin-top: 5px;"
								@click="onCall(item.projectPhone)"
								src="../../static/image/8e25234c881e26577ed04c4c14bd489.png" mode=""></image>
							<!-- <image v-if="item.CentJi == 'pro'" style="width: 20px;height: 20px;" @click="onCall(item.projectPhone)" src="../../static/image/phone1.png" mode=""></image> -->
							<!-- <image v-if="item.low && !item.oneTypes" style="width: 12px;height: 17px;margin-left: 10px;" src="../../static/image/right.png"></image>
								<image v-if="item.low && item.oneTypes" style="width: 19px;height: 17px;margin-left: 10px;" src="../../static/image/mailXiaLa2.png"></image> -->
						</view>
					</view>

				</view>
			</view>
			<view>
				<view style="width: 81%;margin: 17px auto;" v-for="(item2,index2) in item.low">
					<view style="display: flex;border-bottom: 1px solid #e5e5e5;padding-bottom: 11px;margin-top: 25px;"
						@click="handlerClickTwo(index,index2)">
						<view>
							<image style="width: 40px;height: 40px;border-radius: 50%;"
								src="../../static/image/mailDeptImg.png" class="list-img"></image>
						</view>
						<view style="margin-left: 20px;margin-top: 2px;">
							<view>
								<text>{{item2.deptName}}</text>
							</view>
							<view style="margin-top: 5px;color: #999999;">
								电话：{{item2.deptPhone ? item2.deptPhone : '暂无'}}<text></text></view>
						</view>
					</view>

					<view style="float: right;margin-top: -46px;">
						<image style="width: 25px;height: 25px;margin-top: -1px;" @click="onCall(item2.deptPhone)"
							src="../../static/image/8e25234c881e26577ed04c4c14bd489.png" mode=""></image>
					</view>
					<!-- <view v-show="item2.twoTypes" style="width: 89%;margin: 0 auto;" v-if="item2.mailList" v-for="(item3,index3) in item2.mailList">
						<view style="display: flex;">
							<view>
								<image  style="width: 60px;height: 60px;border-radius: 50%;" v-if="item3.user_logo !== null" :src="item3.user_logo" class="list-img"></image>
								<image  style="width: 60px;height: 60px;border-radius: 50%;"v-else src="https://clhy-img.oss-cn-beijing.aliyuncs.com/logo/avatar.jpg" class="list-img"></image>
							</view>
							<view style="margin-top: 8px;margin-left: 20px;">
								<view>
									<text>{{item3.post_name}}</text>
									<text style="margin-left: 20px;">{{item3.employee_name}}</text>
								</view>
								<view style="margin-top: 5px;color: #999999;">电话：13453680526<text></text></view>
							</view>
						</view>
						
						<view style="float: right;margin-top: -46px;">
							<image style="width: 20px;height: 20px;" src="../../static/image/phone1.png" mode=""></image>
						</view>
					</view> -->
				</view>

			</view>
		</view>
		<!-- </viewData> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// project_id:45,
				depomentData: [],
				index: 0,
				pageIndex: 1,
				loading: false,
				// type: 1,
				nextPage: false,
				listData: [],
			}
		},
		onShow() {
			this.getDepoment()
		},
		onPullDownRefresh() {
			this.getDepoment()
		},
		methods: {
			onRefresh() {
				if (!this.nextPage) {
					this.pageIndex = this.pageIndex + 1;
					this.getDepoment();
				}
			},
			onCall(tel) {
				uni.makePhoneCall({
					phoneNumber: tel //仅为示例
				});
			},
			getDepoment() {
				if (this.pageIndex < 2) {
					uni.showLoading({
						title: '加载中'
					});
				}
				this.loading = false;
				pageIndex: this.pageIndex,
					this.$request.api.getdepartment({
						project_id: uni.getStorageSync('projectItem').proId,
					}).then(res => {
						if (this.pageIndex == 1) {
							this.depomentData = res.data.data.dataList || [];
						} else {
							this.depomentData = [...this.depomentData, ...res.data.data.dataList];
						}
						// uni.getStorageSync('PopupList', res.data.data.projectList[0])
						if (this.depomentData.length > 0) {
							for (let i = 0; i < this.depomentData.length; i++) {

								if (res.pro) { //项目下
									if (this.depomentData[i].CentJi == 'pro') {
										this.depomentData[i].oneTypes = true;
									}
								}
							}
						}
						this.nextPage = res.data.data.isEndPage
						this.loading = true;
						uni.hideLoading();
					})
				uni.stopPullDownRefresh()
			},
			//处理点击一级
			handlerClickOne(index) {
				if (this.depomentData[index].oneTypes) {
					this.depomentData[index].oneTypes = false;
				} else {
					this.depomentData[index].oneTypes = true;
				}
			},
			//处理点击二级
			handlerClickTwo(index, index2) {
				if (this.depomentData[index].low[index2].twoTypes) {
					this.depomentData[index].low[index2].twoTypes = false;
				} else {
					this.depomentData[index].low[index2].twoTypes = true;
				}
			}
		}

	}
</script>


<style lang="scss">
	.repair-wrap {
		width: 100%;
		height: auto;
		background: #FFFFFF;
		overflow: hidden;

		.repair-box {
			background: #fff;

			.repair-titel {
				height: 44rpx;
				line-height: 44rpx;

				.repair-titel-l {
					float: left;
				}

				.repair-titel-r {
					float: right;
					color: #999;
				}
			}

			.repair-6 {
				color: #666;
			}
		}
	}

	.tab_nav {
		display: flex;
		justify-content: center;
		align-items: center;
		border-bottom: 1px solid #FFEEEEEE;
	}

	.tab_nav .navTitle {
		height: 90rpx;
		line-height: 90rpx;
		width: 100%;
		text-align: center;
		font-size: 32rpx;
		font-family: Alibaba PuHuiTi;
		color: #333;
	}

	.active {
		position: relative;
		color: #427705;
	}

	.active::after {
		content: "";
		position: absolute;
		width: 100rpx;
		height: 4rpx;
		background-color: #427705;
		left: 0px;
		right: 0px;
		bottom: 0px;
		margin: auto;
	}

	.search {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		color: #427705;
		height: 100rpx;
		border-bottom: 1rpx solid #eeeeee;
		position: relative;

		.search-clear {
			width: 36rpx;
			height: 36rpx;
			position: absolute;
			left: 560rpx;
			top: 50%;
			transform: translateY(-50%);
		}

		.search-input {
			width: 613rpx;
			height: 66rpx;
			background: #f0f2f5;
			border-radius: 33rpx;
			line-height: 66rpx;
			font-size: 28rpx;
			padding: 0 33rpx;
			color: #333333;
			box-sizing: border-box;
		}
	}
</style>